package com.liaozibo.demo.seckill.web.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/product").setViewName("product"); // 后台-查看商品信息
        registry.addViewController("/activity").setViewName("activity"); // 后台-查询活动信息
        registry.addViewController("/buy").setViewName("buy"); // 商品详情页
        registry.addViewController("/settlement").setViewName("settlement"); // 结算页
        registry.addViewController("/pay").setViewName("pay"); // 支付页
        registry.addViewController("/fail").setViewName("fail"); // 秒杀失败页
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
    }
}
